<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="../../base.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>amCharts examples</title>
        <link rel="stylesheet" href="${ctx}/components/chart/amchart/style.css" type="text/css">
        <script src="${ctx}/components/chart/amchart/amcharts/amcharts.js" type="text/javascript"></script>
        <script src="${ctx}/components/chart/amchart/amcharts/serial.js" type="text/javascript"></script>

        <script>
            var chart;
            var graph;

            // months in JS are zero-based, 0 means January
            var chartData = ${charData};


            AmCharts.ready(function () {
                // SERIAL CHART
                chart = new AmCharts.AmSerialChart();

                chart.marginRight = 20;
                chart.marginLeft = 20;
                chart.autoMargins = true;
                chart.dataProvider = chartData;
                chart.categoryField = "hour";
                chart.dataDateFormat = "HH";

                // AXES
                // Category
                var categoryAxis = chart.categoryAxis;
                categoryAxis.parseDates = false; // as our data is date-based, we set parseDates to true
                categoryAxis.minPeriod = "HH"; // our data is yearly, so we set minPeriod to YYYY
                categoryAxis.minorGridEnabled = true;
                categoryAxis.minorGridAlpha = 0.30;

                // VALUE
                var valueAxis = new AmCharts.ValueAxis();
                valueAxis.gridAlpha = 0;
                valueAxis.axisAlpha = 0;
                valueAxis.fillColor = "#000000";
                valueAxis.fillAlpha = 0.10;
                valueAxis.inside = true;
                chart.addValueAxis(valueAxis);

                // GRAPH
                graph = new AmCharts.AmGraph();
                graph.type = "step"; // this line makes step graph
                graph.valueField = "value";
                graph.lineColor = "#000000";
                graph.balloonText = "[[category]]<br><b><span style='font-size:14px;'>[[value]] C</span></b>";
                chart.addGraph(graph);

                // CURSOR
                var chartCursor = new AmCharts.ChartCursor();
                chartCursor.cursorAlpha = 0;
                chartCursor.cursorPosition = "mouse";
                chartCursor.categoryBalloonDateFormat = "HH";
                chart.addChartCursor(chartCursor);

                // SCROLLBAR
                var chartScrollbar = new AmCharts.ChartScrollbar();
                chart.addChartScrollbar(chartScrollbar);

                chart.creditsPosition = "bottom-right";

                // WRITE
                chart.write("chartdiv");
            });
        </script>
    </head>

    <body>
        <div id="chartdiv" style="width:100%; height:400px;"></div>
    </body>

</html>